package QC.MessageBox.beans.dto;

import io.vertx.core.http.HttpServerRequest;

/**
 * Created by Andaren on 2017/5/31.
 * Used for: 分页dto
 */
public class PageInfo {

    private Integer pageNum;

    private Integer pageSize;

    private Integer currentIndex;

    public PageInfo (HttpServerRequest request) {
        this.pageNum = Integer.valueOf(request.getParam("pagenum"));
        this.pageSize = Integer.valueOf(request.getParam("size"));
        currentIndex = (pageNum - 1) * pageSize;
    }

    public Integer getPageNum() {
        return pageNum;
    }

    public PageInfo setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
        return this;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public PageInfo setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
        return this;
    }

    public Integer getCurrentIndex() {
        return currentIndex;
    }

    public PageInfo setCurrentIndex(Integer currentIndex) {
        this.currentIndex = currentIndex;
        return this;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("PageInfo{");
        sb.append("pageNum=").append(pageNum);
        sb.append(", pageSize=").append(pageSize);
        sb.append(", currentIndex=").append(currentIndex);
        sb.append('}');
        return sb.toString();
    }
}
